// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   RouteService.java

package com.itheima.travel.service;

import com.itheima.travel.dao.RouteDao;
import com.itheima.travel.model.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;

public class RouteService
{

	private RouteDao routeDao;

	public RouteService()
	{
		routeDao = new RouteDao();
	}

	public Map routeCareChoose()
		throws Exception
	{
		Map map = new HashMap();
		java.util.List routeList = routeDao.getPopularityRouteList();
		java.util.List newsList = routeDao.getNewestRouteList();
		java.util.List themesList = routeDao.getThemeRouteList();
		map.put("popularity", routeList);
		map.put("news", newsList);
		map.put("themes", themesList);
		return map;
	}

	public PageBean getPageBean(int cid, int curPage, String rname)
		throws Exception
	{
		PageBean pageBean = new PageBean();
		pageBean.setCurPage(curPage);
		int pageSize = 3;
		pageBean.setPageSize(pageSize);
		java.util.List routeList = routeDao.findRouteListByPage(cid, curPage, pageSize, rname);
		pageBean.setData(routeList);
		int count = routeDao.getCountByCid(cid, rname);
		pageBean.setCount(count);
		return pageBean;
	}

	public Route findRouteByRid(String rid)
		throws Exception
	{
		Map map = routeDao.findRouteByRid(rid);
		Route route = new Route();
		BeanUtils.populate(route, map);
		Category category = new Category();
		Seller seller = new Seller();
		BeanUtils.populate(category, map);
		BeanUtils.populate(seller, map);
		route.setCategory(category);
		route.setSeller(seller);
		java.util.List routeImgs = routeDao.findRouteImgsByRid(rid);
		route.setRouteImgList(routeImgs);
		return route;
	}
}
